using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
using Utility;

namespace BUS
{
    public class HinhThucThanhToan_BUS
    {
        public static void Insert(HinhThucThanhToan_DTO hinhThucThanhToan)
        {
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            hinhThucThanhToanDAL.Insert(hinhThucThanhToan);
        }
        public static void Update(HinhThucThanhToan_DTO hinhThucThanhToan)
        {
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            hinhThucThanhToanDAL.Update(hinhThucThanhToan);
        }
        public static void Delete(int iD)
        {
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            hinhThucThanhToanDAL.Delete(iD);
        }
        public static tbHinhThuc_ThanhToanColection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            return hinhThucThanhToanDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhThuc_ThanhToanColection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            return hinhThucThanhToanDAL.Get(cri.Criter, 0, 0, tbHinhThuc_ThanhToanColums.MAHINHTHUC_THANHTOAN.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static HinhThucThanhToan_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbHinhThuc_ThanhToanColums.MAHINHTHUC_THANHTOAN.ToString(), Condition.EQUAL, iD);
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            tbHinhThuc_ThanhToanColection hinhThucThanhToanCollection = hinhThucThanhToanDAL.Get(cri.Criter,
                0, 0, tbHinhThuc_ThanhToanColums.MAHINHTHUC_THANHTOAN.ToString(), OrderDirection.ASC.ToString(), out total);
            if (hinhThucThanhToanCollection.Count > 0)
                return hinhThucThanhToanCollection[0];
            return null;
        }
        public static tbHinhThuc_ThanhToanColection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            return hinhThucThanhToanDAL.Get(cri.Criter, 1, number,
                tbHinhThuc_ThanhToanColums.MAHINHTHUC_THANHTOAN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbHinhThuc_ThanhToanColection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhThucThanhToan_DAL hinhThucThanhToanDAL = new HinhThucThanhToan_DAL();
            return hinhThucThanhToanDAL.Get(cri.Criter, 1, number,
                tbHinhThuc_ThanhToanColums.MAHINHTHUC_THANHTOAN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
